There are probably many answers, depending on the specifics of the situation. But at least one of your scenarios has a certain and definite answer.
I don't think that the FAA has ever issued a legal opinion on this topic, and I kind of doubt they would, but we might be able to piece some answer together.
But first let me address a couple of misconceptions you might have about logging time. In the title and first paragraph of your question, you simply ask about logging time, or logging pilot time. At the end, you ask about PIC or solo time. These are all different kinds of time.
You also wonder whether a pilot could log time, or does the FAA consider that flight to not have had a pilot-in-command. Those are totally different things. Logging pilot time, logging PIC time, and BEING PIC of an aircraft are all different things and don't really have much to do with each other. There are situations where you are PIC and cannot log any time. Other situations where you are not PIC and can log PIC time. Still other situations where you are PIC and can log pilot time, but not PIC time.
To determine whether you ARE ACTING as PIC, you need to look at FAR 1.1: a Pilot in Command
Has final authority and responsibility for the operation and safety of the flight;
Has been designated as pilot in command before or during the flight; and
Holds the appropriate category, class, and type rating, if appropriate, for the conduct of the flight.
That's a totally different section from the regulation that instructs you on how to LOG PIC time, which is FAR 61.51(e):
(1) A sport, recreational, private, commercial, or airline transport pilot may log pilot in command flight time for flights-
(i) ...when the pilot is the sole manipulator of the controls of an aircraft for which the pilot is rated...
In other words, BEING PIC and LOGGING PIC are completely different criteria. And those criteria for logging are that the pilot is rated, not that the pilot is current.
But there is ONE part of 61.51 that does require currency: Let's start with a student who solos after the expiration of their endorsement. FAR 61.51(e)(4) says:
A student pilot may log pilot-in-command time only when the student pilot -
(i) Is the sole occupant of the aircraft or is performing the duties of pilot of command of an airship requiring more than one pilot flight crewmember;
(ii) Has a solo flight endorsement as required under ยง 61.87 of this part; and
(iii) Is undergoing training for a pilot certificate or rating.
So for certain, that student cannot log PIC time.
But now, notice that this is the only place anywhere in 61.51 where currency is required. They make a point of it for student pilots but it doesn't show up anywhere else. So I would be tempted to say that a private pilot can log a flight legally that you weren't allowed to make due to currency. And about generally breaking the rules, I am tempted to add to your list: "I flew to my local uncontrolled field and made right turns in the pattern instead of left turns in violation of 91.126(b)." Do I still get to log the time, even though I flew the wrong pattern? Or what if I accidentally violated an ATC instruction? I think I still log that time. After all, making mistakes and learning from them is what "aeronautical experience" is all about.
So in that same vein, what if I flew out of currency and filed an ASRS report? What if I flew out of currency and didn't file a report? I think it's all the same; I think that breaking a reg doesn't invalidate the time.
There are some FAA opinions that back me up a little bit. In Walker, the FAA gives an opinion about a non-instrument rated pilot who manipulates the controls of an airplane in IMC. Because that pilot is manipulating the controls of an airplane in which they are rated, they log PIC time according to 61.51(e)(1)(1). In that opinion, the flight is legal because their instrument rated friend is occupying a pilot station and acting as PIC (But the friend doesn't log time, even though they are PIC, because they are not manipulating the flight controls).
Perhaps more importantly for your question, that pilot also logs instrument time according to 61.51(b)(3)(2) because the time was acquired in IMC. So a non-instrument rated pilot CAN log instrument time, without a CFII on board, even though he has no instrument rating.
So I think that in general, inadvertently breaking a reg doesn't affect logging, but that is different from saying that such a flight is a very smart or safe thing to do, and if you do log it, you're admitting to a violation in an official record. Also not smart.